package com.headfirst.learning.duck;

import com.headfirst.learning.duck.behavior.FlyBehavior;
import com.headfirst.learning.duck.behavior.QuackBehavior;

/**
 * Created by IntelliJ IDEA.
 * User: IBM
 * Date: 2008-3-27
 * Time: 15:11:42
 * To change this template use File | Settings | File Templates.
 */
public abstract class Duck {
    protected FlyBehavior flyBehavior;
    protected QuackBehavior quackBehavior;

    public void setFlyBehavior(FlyBehavior flyBehavior) {
        this.flyBehavior = flyBehavior;
    }

    public void setQuackBehavior(QuackBehavior quackBehavior) {
        this.quackBehavior = quackBehavior;
    }

    public void fly() {
        flyBehavior.fly();
    }

    public void quack() {
        quackBehavior.quack();
    }

    public void swim() {
        System.out.println("swiming");
    }
}
